<template>
    <view class="listBox">
        <view class="back_fff list">
            <view class="flex justify_content_between" @click="buybtn(item)">
                <view class="type">{{item.order_text}}</view>
                <view class="time">{{item.createtime }}</view>
            </view>
            <view class="flex justify_content_between pt_24" @click="buybtn(item)">
                <view class="round"></view>
                <view class="title">{{ item.trailer_address}}</view>
            </view>
            <view class="flex justify_content_between pt_24" @click="buybtn(item)">
                <view class="round" style="background: #3377ff"></view>
                <view class="title">
                    <view class="address">{{item.user_location }}</view>
                    <view>
                        <text class="name">{{ item.consignee }}</text>
                        <text class="iphone">{{ $lz.desensitize(item.mobile) }}</text>
                    </view>
                </view>
            </view>
            <view class="money pt_24">
                费用
                <text>¥ {{ item.actual_price }}</text>
            </view>
			<!-- order_schedule 0是骑手正在前往商家 1是骑手已到商家 2是已取货 3已送到 -->
            <view class="flex btn justify_content_end">
                <view class="cance" @click="q_order(item.id)" v-if="item.order_status==0">取消订单</view>
				<view class="cance" @click="y_q_order(item.id)" v-if="item.order_status==1&&item.rider_status==1">取消订单</view>
                <view class="buy" @click="buybtn(item,1)" v-if="item.order_status==0">立即付款</view>
				<!-- <view class="buy" @click="buybtn(item,2)" v-if="item.order_status==1&&item.rider_status==0">订单详情</view>
				<view class="buy" @click="buybtn(item,2)" v-if="item.order_status==1&&item.rider_status==4">订单详情</view>
                <view class="buy" @click="inProgress(item.id,0)" v-if="item.order_status==1&&item.rider_status==1">订单详情</view>
				<view class="buy" @click="inProgress(item.id,0)" v-if="item.order_status==1&&item.rider_status==2">订单详情</view>
				<view class="buy" @click="inProgress(item.id,0)" v-if="item.order_status==1&&item.rider_status==3">订单详情</view> -->
				<view class="buy" @click="inProgress(item.id,0)" v-if="item.order_status==1&&item.rider_status==3">导航去商家</view>
				<view class="buy" @click="inProgress(item.id,0)" v-if="item.order_status==1&&item.rider_status==3">导航去用户</view>
                <view class="buy" @click="user_wc(item.id)" v-if="item.rider_status==1||item.rider_status==2||item.rider_status==3">完成服务</view>
                <view class="buy" @click="evaluate(item.id)" v-if="item.order_status==1&&item.rider_status==4&&item.is_p==0">去评价</view>
                <!-- <view class="buy" @click="AfterSalesDetails">售后详情</view> -->
            </view>
        </view>
    </view>
</template>
<script>
import { getDictByCode } from "@/api"
export default {
    name: 'order-item-goods',
    props: {
        item: {
            type: Object,
            default: () => { }
        }
    },
    data() {
        return {
            dicts: {}
        };
    },
    // beforeMount() {
    //     getDictByCode('service_mode').then(({ data }) => {
    //         const vaules = data.reduce((accu, curr) => ({...accu,[curr.key]:curr.title}), {});
    //         console.log(vaules)
    //         this.dicts = vaules
    //         console.log(this.dicts[this.item.meta.type],this.item.meta.type)
    //     })
    // },
    // watch: {
    //    "item.meta.mode":(value,_)=>console.log(value)
    // },
    computed: {
        modeDict: ()=> ''//this.dicts.get(item.meta.mode)
    },
	onShow() {
	    uni.$on('evaluate',function(data){
			   console.log(data)
			  this.$emit('handleGetOrderList')
	    })	
	},
    methods: {
		//未支付取消
		q_order(id){
			this.$.ajax(1, "POST", "users/q_order", {
					id:id,
				}, (res) => {
					if(res.code==200){
						this.$.ti_shi(res.msg)
						 setTimeout(()=>{
							 this.$emit('handleGetOrderList')
						 },1000)
						 
					}else{
						this.$.ti_shi(res.msg)
					}
				})
		},
		user_wc(id){
			this.$.ajax(1, "POST", "users/user_wc", {
					order_id:id,
				}, (res) => {
					if(res.code==200){
						this.$.ti_shi(res.msg)
						 setTimeout(()=>{
							 this.$emit('handleGetOrderList')
						 },1000)
						 
					}else{
						this.$.ti_shi(res.msg)
					}
				})
		},
		//已支付取消
		y_q_order(id){
			uni.navigateTo({
			    url: '/pages/me/MyOrder/CarCancel?id=' + id
			});
		},
        buybtn(id,t) {
			// if(id.order_status==0){
			// 	uni.navigateTo({
			// 	    url: '/pages/me/MyOrder/ServiceOrders?id=' + id.id+'&t='+t
			// 	});
			// }
			if(id.order_status==1&&id.rider_status==0){
				uni.navigateTo({
				    url: '/pages/me/MyOrder/ServiceOrders?id=' + id.id+'&t='+2
				});
			}
			if(id.order_status==1&&id.rider_status==4){
				uni.navigateTo({
				    url: '/pages/me/MyOrder/ServiceOrders?id=' + id.id+'&t='+2
				});
			}
			if(id.order_status==1&&id.rider_status==1){
				uni.navigateTo({
				    url: '/pages/me/MyOrder/inProgress?id=' + id.id
				});
			}
			if(id.order_status==1&&id.rider_status==2){
				uni.navigateTo({
				    url: '/pages/me/MyOrder/inProgress?id=' + id.id
				});
			}
			if(id.order_status==1&&id.rider_status==3){
				uni.navigateTo({
				    url: '/pages/me/MyOrder/inProgress?id=' + id.id
				});
			}
			
			
            
        },
        evaluate(id) {
            uni.navigateTo({
                url: '/pages/me/MyOrder/evaluate?id=' + id
            });
        },
        AfterSalesDetails() {
            uni.navigateTo({
                url: '/pages/me/MyOrder/AfterSalesDetails'
            });
        },
        inProgress(id) {
            uni.navigateTo({
                url: '/pages/me/MyOrder/inProgress?id=' + id
            });
        }
    }
};
</script>

<style scoped lang="scss">
.list {
    padding: 24rpx;
    border-radius: 24rpx;
    margin-top: 24rpx;

    .round {
        width: 16rpx;
        height: 16rpx;
        border-radius: 50%;
        background: #00091a;
        font-size: 28rpx;
        margin-top: 16rpx;
    }

    .type {
        color: #3377ff;
        font-weight: bold;
    }

    .time {
        color: #ccced1;
    }

    .title {
        width: 90%;
        color: #00091a;
        font-size: 32rpx;
        font-weight: bold;
    }

    .address {
        display: inline-block;
        white-space: nowrap;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .name {
        font-weight: normal;
        color: #333a47;
        margin-right: 24rpx;
    }

    .iphone {
        font-weight: normal;
        color: #999ca3;
    }

    .money {
        text-align: right;
        color: #666b75;
    }

    .money text {
        color: #ff6401;
        font-weight: bold;
        font-size: 32rpx;
    }

    .btn {
        text-align: right;
    }

    .cance {
        width: 160rpx;
        height: 68rpx;
        line-height: 68rpx;
        border-radius: 8rpx;
        color: #666b75;
        text-align: center;
        border: 2rpx solid #ccced1;
        margin-top: 24rpx;
    }

    .buy {
        width: 160rpx;
        height: 68rpx;
        line-height: 68rpx;
        border-radius: 8rpx;
        color: #ffffff;
        text-align: center;
        background: #3377ff;
        margin-left: 24rpx;
        margin-top: 24rpx;
    }
}
</style>
